package com.qumoyugo.springframework.context.event;

import com.qumoyugo.springframework.context.ApplicationEvent;
import com.qumoyugo.springframework.context.ApplicationListener;
import com.qumoyugo.springframework.beans.factory.BeanFactory;

/**
 * @author Cedric
 * @date 2021/11/29 14:16
 * @description 简单事件广播
 */
public class SimpleApplicationEventMulticaster extends AbstractApplicationEventMulticaster {

    public SimpleApplicationEventMulticaster(BeanFactory beanFactory) {
        setBeanFactory(beanFactory);
    }

    @Override
    @SuppressWarnings("unchecked")
    public void multicastEvent(ApplicationEvent event) {
        for(ApplicationListener listener : getApplicationListeners(event)) {
            listener.onApplicationEvent(event);
        }
    }
}
